home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / brklyprl.lha / Emulator / Benchmarks / output / hanoi.pl < prev    next >
Encoding:
Text File  |  1989-04-14  |  262 b   |  13 lines

  1. %    towers of hanoi ( hanoi ) for 8 disks
  2.  
  3. main :- hanoi(8).
  4.  
  5. hanoi(N) :- move(N,left,center,right).
  6.  
  7. move(0,_,_,_) :- !.
  8. move(N,A,B,C) :- M is N-1, move(M,A,C,B), inform(A,B), move(M,C,B,A).
  9.  
  10. inform(A,B) :- write([move,disk,from,A,to,B]), nl, fail.
  11. inform(_,_).
  12.  
  13.